from overrides import override
import typing as T
from langchain_core.documents import Document

from . import IFileSpliter


class PDFSpliter(IFileSpliter):
    @override
    def spliter(
        self,
        documents: T.List[Document],
        chunk_size: int = 256,
        chunk_overlap: int = 128,
    ) -> T.List[Document]:
        from langchain.text_splitter import RecursiveCharacterTextSplitter

        text_splitter = RecursiveCharacterTextSplitter(
            chunk_size=chunk_size, chunk_overlap=chunk_overlap
        )
        return text_splitter.split_documents(documents)
